package com.aoxon.cargo.component;

import java.util.List;

import android.content.Intent;

import com.aoxon.cargo.activity.PurGoodsPagerActivity;
import com.aoxon.cargo.bean.GsonBean;
import com.aoxon.cargo.component.n.WaterFallGoodsView;
import com.aoxon.cargo.service.GoodsFromSupplierService;
import com.aoxon.cargo.service.HotGoodsService;
import com.aoxon.cargo.service.MyServiceFactory;
import com.aoxon.cargo.service.NewGoodsService;
import com.aoxon.cargo.service.SearchHotGoodsFromTextService;
import com.aoxon.cargo.service.SearchNewGoodsFromTextService;

/**
 * 加载物品信息的类
 * 
 * @author ZZJ
 * 
 */
public class MyLoadCloth {

	public final static int INDEX_NEW = 0; // 首页最新
	public final static int INDEX_HOT = 1;// 首页最热
	public final static int SUP_CLOTH = 2; // 供应商物品详情
	public final static int SEARCH_NEW = 3;// 检索最新
	public final static int SEARCH_HOT = 4;// 检索最热
	public final static int COLLECT = 5;// 收藏

	public static String search_text = "";
	public static int sup_id = 0;
	public static List<?> clothList;
	public static WaterFallGoodsView waterFallGoodsView;

	private NewGoodsService newGoodsService = (NewGoodsService) MyServiceFactory
			.getInstance(MyServiceFactory.NEW_GOODS);
	private HotGoodsService hotGoodsService = (HotGoodsService) MyServiceFactory
			.getInstance(MyServiceFactory.HOT_GOODS);

	private SearchHotGoodsFromTextService searchHotGoodsService = (SearchHotGoodsFromTextService) MyServiceFactory
			.getInstance(MyServiceFactory.SEARCH_HOT_GOODS);
	private SearchNewGoodsFromTextService searchNewGoodsService = (SearchNewGoodsFromTextService) MyServiceFactory
			.getInstance(MyServiceFactory.SEARCH_NEW_GOODS);

	private GoodsFromSupplierService goodsFromSupplierService = (GoodsFromSupplierService) MyServiceFactory
			.getInstance(MyServiceFactory.GOODS_FROM_SUPPLIER);

	public GsonBean loadCloths(int startIndex, int length, int loadType) {

		switch (loadType) {
		case 0:
			return newGoodsService.execute(startIndex, length);
		case 1:
			return hotGoodsService.execute(startIndex, length);
		case 2:
			return goodsFromSupplierService.execute(startIndex, length, sup_id);
		case 3:
			return searchNewGoodsService.execute(startIndex, length,
					search_text);
		case 4:
			return searchHotGoodsService.execute(startIndex, length,
					search_text);
		case 5:

		default:
			break;
		}
		return null;
	};

	/**
	 * 设置跳转到物品详情页的参数
	 * 
	 * @param intent
	 * @param startIndex
	 * @param length
	 * @param loadType
	 * @param start_item
	 * @param strCloths
	 */
	/*
	 * public static void setExtra(Intent intent, int startIndex, int length,
	 * int loadType, int start_item, String strCloths) {
	 * PurGoodsPagerActivity.START_ITEM = start_item; intent.putExtra("cloths",
	 * strCloths); intent.putExtra("startIndex", startIndex);
	 * intent.putExtra("length", length); intent.putExtra("loadType", loadType);
	 * }
	 */
	public static void setExtra(Intent intent, int startIndex, int length,
			int loadType, int start_item, List<?> list) {

		clothList = list;
		PurGoodsPagerActivity.START_ITEM = start_item;
		intent.putExtra("startIndex", startIndex);
		intent.putExtra("length", length);
		intent.putExtra("loadType", loadType);
	}

}
